SUIPatternLibrary.PatternSelectDialog = function(){
var
    that = {},
    $dialog = undefined,

    createButtons = function(patternNames){
        var buttons = {};
        for(var i = 0, max = patternNames.length; i < max; i++){
            buttons[patternNames[i]] = createButtonClickFunction(patternNames[i]);
        }
        return buttons;
    },

    createButtonClickFunction = function(patternName){
        return function(){
            $dialog.dialog("close");
            $(that).trigger("patternClick", patternName)
        };
    },

    init = function(patternNames){
        $dialog = $("<div class='pattern-select-dialog' title='Select Pattern'></div>");
        $dialog.text("There are multiple Patterns available. Please select one");
        $dialog.dialog({
            modal: true,
            autoOpen: true,
            show: "fade",
            hide: "fade",
            buttons : createButtons(patternNames)
        });
    };

    that.dialog = $dialog;
    that.init = init;

    return that;

};